public class frwe {
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

    public class Demo99 {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入要扫描的根目录(绝对路径或者相对路径");
            String rootDirPath = scanner.next();
            File rootDir = new File(rootDirPath);
            System.out.println("请输入要找出的文件名");
            String Filmname= scanner.next();
            if(!rootDir.isDirectory()){
                System.out.println("您输入的根目录不存在或者不是目录,退出");
                return;
            }
            scanDir(rootDir,Filmname);

        }

        private static void scanDir(File rootDir, String filmname) {
            File[] files = rootDir.listFiles();
            if(files == null){
                return;
            }
            for (File f:files) {
                if(!f.isFile()){
                    if(filmname.equals(f.getName())){
                        System.out.println("找到了"+f.getAbsolutePath());
                    }
                } else if (f.isDirectory()) {
                    scanDir(f,filmname);
                }
            }
        }
    }

}
